﻿using System;
using System.Data;
using System.Collections.Generic;
using ChinaSoft.Common;
using ChinaSoft.Model;
namespace ChinaSoft.BLL
{
	/// <summary>
	/// 保险公司维护
	/// </summary>
	public partial class BLL_T_SYS_INSURER
	{
		private readonly ChinaSoft.DAL.DAL_T_SYS_INSURER dal=new ChinaSoft.DAL.DAL_T_SYS_INSURER();
		public BLL_T_SYS_INSURER()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string INSURER_ID)
		{
			return dal.Exists(INSURER_ID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(ChinaSoft.Model.Model_T_SYS_INSURER model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ChinaSoft.Model.Model_T_SYS_INSURER model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string INSURER_ID)
		{
			
			return dal.Delete(INSURER_ID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string INSURER_IDlist )
		{
			return dal.DeleteList(INSURER_IDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ChinaSoft.Model.Model_T_SYS_INSURER GetModel(string INSURER_ID)
		{
			
			return dal.GetModel(INSURER_ID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public ChinaSoft.Model.Model_T_SYS_INSURER GetModelByCache(string INSURER_ID)
		{
			
			string CacheKey = "Model_T_SYS_INSURERModel-" + INSURER_ID;
			object objModel = ChinaSoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(INSURER_ID);
					if (objModel != null)
					{
						int ModelCache = ChinaSoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						ChinaSoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (ChinaSoft.Model.Model_T_SYS_INSURER)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_T_SYS_INSURER> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_T_SYS_INSURER> DataTableToList(DataTable dt)
		{
			List<ChinaSoft.Model.Model_T_SYS_INSURER> modelList = new List<ChinaSoft.Model.Model_T_SYS_INSURER>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				ChinaSoft.Model.Model_T_SYS_INSURER model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new ChinaSoft.Model.Model_T_SYS_INSURER();
					if(dt.Rows[n]["INSURER_ID"]!=null && dt.Rows[n]["INSURER_ID"].ToString()!="")
					{
					model.INSURER_ID=dt.Rows[n]["INSURER_ID"].ToString();
					}
					if(dt.Rows[n]["NAME"]!=null && dt.Rows[n]["NAME"].ToString()!="")
					{
					model.NAME=dt.Rows[n]["NAME"].ToString();
					}
					if(dt.Rows[n]["CODE"]!=null && dt.Rows[n]["CODE"].ToString()!="")
					{
					model.CODE=dt.Rows[n]["CODE"].ToString();
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

